package com.example.cmtwo.controller;

import com.example.cmtwo.service.OwnAdviseService;
import com.example.cmtwo.service.OwnReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class OwnBackController
{
    @Autowired
    private OwnReportService ownReportService;
    @Autowired
    private OwnAdviseService ownAdviseService;

    @RequestMapping(value = "/submit1", method = RequestMethod.POST)
    @ResponseBody
    public boolean submit1(@RequestParam("Uid") Integer id, @RequestParam("Who") Integer who,
                           @RequestParam("Type") String type,@RequestParam("Phone") Integer phone,
                           @RequestParam("Why") String why)
    {
        System.out.println(id);
        System.out.println(who);
        System.out.println(type);
        System.out.println(phone);
        System.out.println(why);
        boolean result;
        result = ownReportService.insertReport(id, who, type, phone, why);

        return result;
    }

    @RequestMapping(value = "/submit2", method = RequestMethod.POST)
    @ResponseBody
    public boolean submit1(@RequestParam("Uid") Integer id, @RequestParam("Funtion") String funtion,
                           @RequestParam("Phone") Integer phone, @RequestParam("Content") String content)
    {
        boolean result;
        result = ownAdviseService.insertAdvise(id, funtion, phone, content);

        return result;
    }
}
